﻿using UnityEngine;
using System.Collections;

public class MouseCamera : MonoBehaviour {

	RaycastHit hit;

	public GameObject Target;
	
	private float raycastLength = 500;

	void Update()
	{


				Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);

				if (Physics.Raycast (ray, out hit, raycastLength)) {
						if (hit.collider.name == "Terrain") {

								if (Input.GetMouseButtonDown (1)) {
										GameObject TargetObj = Instantiate (Target, hit.point, Quaternion.identity) as GameObject;
										TargetObj.name = "Target Instantiated";


		      
								}
						}


	   


				}


		}

}